package com.huaxinkai.mobile.socket;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * URL常用方法
 * @author liuzh
 * @date 2017年1月14日下午10:00:38
 */
public class UrlTest {

	public static void main(String[] args) {
		try {
			URL qq = new URL("http://www.13ij.com");
			URL url = new URL(qq,"/goods.htm?id=197");
			System.out.println("协议："+url.getProtocol());
			System.out.println("主机："+url.getHost());
			//如果未指定端口号  则默认80端口，返回值-1
			System.out.println("端口："+url.getPort());
			System.out.println("文件路劲："+url.getFile());
			System.out.println("相对路径："+url.getRef());
			System.out.println("查询字符串："+url.getQuery());
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
		

	}

}
